package com.woniuxy.qiantai.controller;


import com.woniuxy.qiantai.entity.Booktype;
import com.woniuxy.qiantai.service.BookService;
import com.woniuxy.qiantai.service.BooktypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author woniumrwang
 * @since 2023-01-08 07:35:18
 */
@RestController
@RequestMapping("/booktype")
public class BooktypeController {
    @Autowired
    private BooktypeService booktypeService;
    @Cacheable(value = "bookType",key = "#root.targetClass+#root.methodName")
    @RequestMapping("/all")
    public   List<Booktype> all(){
        List<Booktype> list = booktypeService.list();
        System.out.println("查询全部图书类型");
        return list;
    }
    @RequestMapping("getByTypeId")
    public Booktype getByTypeId(Integer typeId){
        Booktype booktype = booktypeService.getById(typeId);
        return booktype;
    }

}

